<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/2
 * Time: 13:41
 */
echo '<pre>';
require 'functions.php';
function load_file()
{
    //加载文件配置
    config(include('config/database.php'));
    config(include('config/server.php'));
}

function auto_load_dir($dir)
{
    $list = glob($dir . '*.php');
    foreach ($list as $file) {
        if (is_file($file)) {
            $filename = pathinfo($file, PATHINFO_FILENAME);
            config(include($file), $filename);
        }
    }
}

//1.直接加载文件
load_file();

//2.文件加载,以文件名做存储键
$dir = str_replace('\\', '/', __DIR__ . '/config/');
auto_load_dir($dir);

//3.设置临时值
config('name', mt_rand(0, 10));
config('php.name', 'php-hello');

//4.获取值
$rs = config('database.host');//文件名.存储健
var_dump($rs);
//读取全部的结果
var_dump(config());